package com.maxwell.googleplay.fragment;

import java.util.List;
import java.util.Random;

import com.maxwell.googleplay.base.BaseFragment;
import com.maxwell.googleplay.base.LoadingPager.LoadedResult;
import com.maxwell.googleplay.base.SuperBaseAdapter;
import com.maxwell.googleplay.bean.SubjectInfoBean;
import com.maxwell.googleplay.factory.ListViewFactory;
import com.maxwell.googleplay.holder.BaseHolder;
import com.maxwell.googleplay.holder.SubjectHolder;
import com.maxwell.googleplay.protocol.SubjectProtocol;
import com.maxwell.googleplay.utils.UIUtils;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.TextView;

/**
 * @author yue
 * @创建时间 2016-3-30上午9:26:27
 * @描述 TODO
 * 
 */
public class SubjectFragment extends BaseFragment {
	private List<SubjectInfoBean> mDatas;

	@Override
	public LoadedResult initData() {
		SubjectProtocol protocol = new SubjectProtocol();
		try {
			mDatas = protocol.loadData(0);
			return checkState(mDatas);

		} catch (Exception e) {
			e.printStackTrace();
			return LoadedResult.ERROR;
		}
	}

	@Override
	public View initSuccessView() {
		ListView listView = ListViewFactory.createListView();
		listView.setAdapter(new SubjectAdapter(listView, mDatas));

		return listView;
	}
	
	
	class SubjectAdapter extends SuperBaseAdapter<SubjectInfoBean>{

		public SubjectAdapter(AbsListView absListView,
				List<SubjectInfoBean> dataSource) {
			super(absListView, dataSource);
			// TODO Auto-generated constructor stub
		}

		@Override
		public BaseHolder<SubjectInfoBean> getSpecialHolder(int position) {
			
			return new SubjectHolder();
		}
		
		
		
	}
}
